package cn.stylefeng.guns.modular.web.controller;

import cn.stylefeng.guns.core.ParamUtil;
import cn.stylefeng.guns.modular.rw.entity.InfoSet;
import cn.stylefeng.guns.modular.rw.service.*;
import cn.stylefeng.roses.core.base.controller.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 描述：关于我们 controller
 * 作者：chenhuiyan
 * 时间：2020-05-07
 */
@Controller
@RequestMapping(value = "/web/aboutMe")
public class WebAboutMeController extends BaseController {

    private String PREFIX = "/modular/web/";

    @Autowired
    private IInfoSetService infoSetService;

    @Autowired
    private ICarouselService carouselService;

    @Autowired
    private IIndexBannerOneService indexBannerOneService;

    @Autowired
    private IIndexBannerTwoService indexBannerTwoService;

    @Autowired
    private IIndexVideoService indexVideoService;

    @Autowired
    private IBannerService bannerService;

    /**
     * 跳转到首页
     */
    @RequestMapping(value = "/")
    public String index() {
        return PREFIX + "aboutMe.html";
    }

    /**
     * 初始化数据
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getInitData")
    public Map<String, Object> getInitData(){
        Map<String, Object> res = new HashMap<>();

        Map<String, Object> params = ParamUtil.getParams();

        //查询基本配置
        InfoSet infoSet = infoSetService.getBaseMapper().selectList(new QueryWrapper<InfoSet>()).get(0);

        //查询首页区块二
        Map<String, Object> indexBannerTwo = indexBannerTwoService.list(params).getRecords().get(0);

        //查询首页视频展区
        List<Map<String, Object>> indexVideoList = indexVideoService.getList(params);

        //banner首页视频区背景图
        params.put("webType", "0");
        Map<String, Object> videoBanner = bannerService.list(params).getRecords().get(0);

        //banner关于我们背景图
        params.put("webType", "4");
        Map<String, Object> aboutMeBanner = bannerService.list(params).getRecords().get(0);

        res.put("infoSet", infoSet);
        res.put("indexBannerTwo", indexBannerTwo);
        res.put("indexVideoList", indexVideoList);
        res.put("videoBanner", videoBanner);
        res.put("aboutMeBanner", aboutMeBanner);

        return res;
    }

}
